package com.app.motion.bind;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ButterKnife {

    private ButterKnife() {

    }

    private static void init(Object obj) {
        Class<?> clz = obj.getClass();
        String className = clz.getName() + "$Binding";
        try {
            Class bindClass = clz.getClassLoader().loadClass(className);
            Constructor constructor = bindClass.getConstructor(clz);
            constructor.newInstance(obj);
        } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    public static void bind(Object obj) {
        init(obj);
    }
}
